package learningspringboot.beanLifeCycles.part1;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanLifeCycle {

    public static void main(String[] args) {
        System.out.println("Spring容器初始化");
        System.out.println("=====================================");

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-beans.xml");

        System.out.println("Spring容器初始化完毕");
        System.out.println("=====================================");

        System.out.println("从容器中获取Bean");

        GiraffeService service = context.getBean("giraffeService", GiraffeService.class);

        System.out.println("giraffe Name="+service.getName());
        System.out.println("=====================================");

        context.close();

        System.out.println("Spring容器关闭");
    }
}
